package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class add implements IOperation{
    @Override
    public void work(BookList Booklist) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请依次输入增添书籍的书名，作者，价格，类型：");
        Book newbook = new Book(scanner.next(), scanner.next(), scanner.nextDouble(), scanner.next());
        find find = new find();
        int number = find.find_name(Booklist,newbook.getBookname());
        if(number<0) {
            Booklist.expansion();
            Booklist.getBooklist()[Booklist.getCount()] = newbook;
            Booklist.setCount(Booklist.getCount()+1);
            System.out.println("书籍增加成功");
        } else {
            System.out.println("该书已经存在，书籍增加失败");
        }

    }
}